﻿using System;
using System.IO;
using System.Reflection;
using System.Web;
using System.Web.UI;
using AnyOffice.BIZ;
using log4net;

namespace AnyOffice.module.oc
{
    public partial class uploaddisk : Page
    {
        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
       
        protected void Page_Load(object sender, EventArgs e)
        {
            string str = (Request.Form["attachment_id"] == null) ? "" : Request.Form["attachment_id"].ToString();
            HttpFileCollection files = Request.Files;
            for (int i = 0; i < files.Count; i++)
            {
                HttpPostedFile file = files[i];
                if (files.GetKey(i).ToUpper() == "EDITFILE")
                {
                    try
                    {
                        string str2 = file.FileName.Substring(file.FileName.LastIndexOf('\\') + 1);
                        FileInfo info = new FileInfo(Server.MapPath(AttachmentBiz.AttachmentPath) + @"\" + str + @"\" + str2);
                        if (info.Exists)
                        {
                            file.SaveAs(info.FullName);
                            Response.Write("文件'" + str2 + "'保存成功！");
                        }
                        else
                        {
                            Response.Write("文件'" + str2 + "'保存失败！");
                        }
                    }
                    catch (Exception exception)
                    {
                        if (log.IsErrorEnabled)
                        {
                            log.Error("", exception);
                        }
                    }
                }
            }
        }

    }
}
